export const Throttle = (fn, t) => {
    let last;
    let timer;
    let interval = t || 500;

    return function () {
        let args = arguments;
        let now = +new Date();
        if (last && now - last < interval) {
            clearTimeout(timer);
            timer = setTimeout(() => {
                last = now;
                fn.apply(this, args);

            }, interval);
        } else {
            last = now;
            fn.apply(this, args);
        }
    }
};

export const antiShake = (func, wait = 500) => {
    let timeout
    return function (event) {
        clearTimeout(timeout)
        timeout = setTimeout(() => {
            func.call(this, event)
        }, wait)
    }
}

